"""Controller for current students."""

from mnemoply.controllers.lookup import TableLookupDataSource
from mnemoply.controllers.Student import StudentController

class CurrentStudentDataSource(TableLookupDataSource):
    """
        Provides `student_lookup` with filtration by current year.
    """

    def __init__(self):
        TableLookupDataSource.__init__(self, 'student_lookup')

    def _buildWhereChunks(self, request):
        chunks = TableLookupDataSource._buildWhereChunks(self, request)
        chunks.append("(cache_in_groups > 0)")  # see schema-addon/views.sql
        return chunks

class CurrentStudentController(StudentController):
    """Controller for current students."""

    def __init__(self):
        StudentController.__init__(self, data_source=CurrentStudentDataSource())
        self.title = _("Current student")

exposed = CurrentStudentController()
